// index.js
// 获取应用实例
const app = getApp()
Page({
  data: {
    srcMic: 'music/遊戯王-热烈的决斗者.mp3'
    // https://wj1.kumeiwp.com:812/wj/bl/2022/03/26/8d9ac21a34e451cf2decfdbf6147de5f.mp3?t=1687864479&key=2e5c967447f9f3ee7190
  },
  onLoad() {
    // this.audioPlay();
  },
  onShow() {
    this.audioPlay();
  },
  onHide () {
    this.innerAudioContext.stop()
  },
  audioPlay() {
    //创建内部 audio 上下文 InnerAudioContext 对象。
    this.innerAudioContext = wx.createInnerAudioContext();
    this.innerAudioContext.src = this.data.srcMic //设置音频地址
    this.innerAudioContext.loop = true // 是否循环播放
    this.innerAudioContext.play(); //播放音频
  },
  stopPlay () {
    this.innerAudioContext.pause()
  },
  onUnload () {
    this.innerAudioContext.stop()
  },
 
})